interface EventList {
	name: string;
	callback: (...args: any[]) => any;
}

export class SGS_Event {
	private eventList: EventList[] = [];
	constructor() {}

	on(name: string, callback: (...args: any[]) => any): void;
	on(name: string[], callback: (...args: any[]) => any): void;
	on(name: string | string[], callback: (...args: any[]) => any): void {
		if (typeof name === "string") {
			this.eventList.push({
				name,
				callback
			});
		} else {
			name.forEach(v => {
				this.eventList.push({
					name: v,
					callback
				});
			});
		}
	}

	emit(name: string): void;
	emit(name: string[]): void;
	emit(name: string | string[]): void {
		for (let i = 0; i < this.eventList.length; i++) {
			if (typeof name === "string" && this.eventList[i].name === name) {
				this.eventList[i].callback();
				break;
			} else if (name.includes(this.eventList[i].name)) {
				this.eventList[i].callback();
				continue;
			}
		}
	}
}
